package com.uperform.coach.tdd.domain;

import org.springframework.stereotype.Component;

@Component
public class NewTaskService {
    private final TaskRepository taskRepository;

    public NewTaskService(TaskRepository taskRepository) {

        this.taskRepository = taskRepository;
    }

    public void execute(NewTaskRequest request) {
        Task task = request.toEntity()
                .ensureCycleTimeValid()
                .updateNextExecute();
        taskRepository.save(task);
    }
}
